#include <QApplication>
#include <QString>
#include <QTextCodec>
#include <string>
#include <fstream>
#include "newsviewer.hpp"

using namespace std;
int main(int argc,char* argv[]){
    QApplication app(argc,argv);

    int newsnum;
    string newscontent[100],newslink[100];
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
    ifstream fin("D:/news.txt");
    if(fin.is_open()==false)return 0;
    fin>>newsnum;
    string a;
    getline(fin,a);
    for(int i=0;i<newsnum;i++)
    {
        getline(fin,newslink[i]);
        getline(fin,newscontent[i]);
    }
    fin.close();
/*
    QFile file("D:/news.txt");
    file.open(QIODevice::ReadOnly);
    QTextStream fin(&file);
    QString newscontent[100],newslink[100];
*/

    NewsViewer *dialog = new NewsViewer(newsnum,newscontent,newslink);
    dialog->show();

    return app.exec();
}
